<%@ page import="com.system.dao.DoctorDao"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="ui" uri="http://com.am.tag" %>
<%@ include file="../common.jsp" %>
<%
	DoctorDao dao = new DoctorDao();
	Map<String,Object> map = dao.getPrescriptionBase(request.getParameter("record_id"));
	pageContext.setAttribute("personMap", map.get("personMap"));
	pageContext.setAttribute("diagnoseMap", map.get("diagnoseMap"));
	pageContext.setAttribute("list", map.get("list"));
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'prescription.jsp' starting page</title>
    <style type="text/css">
    	#receipt {
    		position:absolute;
    		text-align:left;
			width:125px;
			height:100%;
			top:150px;
			left:350px;
		}
		#title {
			font-family: "微软雅黑", Verdana, Arial, Helvetica, sans-serif;
    		font-size:22px;
    		color:#242424;
    		font-weight:bold;
		}
		.general{
			BORDER-RIGHT: medium none;
			BORDER-TOP: medium none;
			BORDER-LEFT: medium none;
			BORDER-BOTTOM: rgb(192,192,192) 1px solid;
			text-align:center;
		}
    </style>
    <!-- 插入打印控件 -->
      <OBJECT  ID="jatoolsPrinter" CLASSID="CLSID:B43D3361-D075-4BE2-87FE-057188254255"
                  codebase="jatoolsPrinter.cab#version=8,6,0,0"></OBJECT>  
    
    
    <script type="text/javascript">
    	function doPrint(how) { 
   			 var myDoc = {
   			 	settings:{paperName:'a5'},   // 选择a4纸张进行打印
   			 	//settings:{orientation:2},   // 选择横向打印,1为纵向，2为横向
   			 	/*settings:{topMargin:100,
		                  leftMargin:100,
		                  bottomMargin:100,
		                  rightMargin:100},   // 设置上下左距页边距为10毫米，注意，单位是 1/10毫米
		        settings:{printer:'OKi5530'},//设置到打印机 'OKi5530'
		        */
        		documents: document,
        		copyrights: '杰创软件拥有版权  www.jatools.com'
   			 }; 
	   		 if (how == '打印预览...') {
	        	 jatoolsPrinter.printPreview(myDoc);} // 打印预览
	    	 else if (how == '打印...') {
	         	jatoolsPrinter.print(myDoc, false); // 打印前弹出打印设置对话框
	         	}
	    	else
	         	jatoolsPrinter.print(myDoc, false); // 不弹出对话框打印
		}
    
    	$().ready(function(){
    		$("#print_time").val(new Date().toLocaleTimeString());
    		var len = "${fn:length(list)}";
    		if(len == 0)
    		{
    			alert("请先诊断");
    			Dialog.getInstance("view1").close();
    		}
    		var total = 0;
			$("input[name='amount']").each(function(){
					total = add(total,$(this).val());
			});
			$("#amountTotal").val(total+"元");
    		doPrint('打印...');
    	});
    	
    	function add(arg1,arg2){ 
			var r1,r2,m; 
			try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0} 
			try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0} 
			m=Math.pow(10,Math.max(r1,r2)) ;
			return (arg1*m+arg2*m)/m ;
		}
    </script>
  </head>
  
  <body style="overflow-x: hidden;">
	 <%--  <div style="margin-left:490px;margin-top:10px;">
	  	<ui:Permission value="doctor_prescription_print">
	  		<input type="button"  style="background:url(${path }/images/common/hp_printer.png); width:64px;height:64;border:0" onclick="doPrint('打印预览...')">
	  	</ui:Permission>
	  </div> --%>

  <div id="page1" style="font-size:11">
  	<div style="width:100%">
	 	 <div style="margin-left:8%;float:left">
		  	<img src="${path }/images/common/logo.jpg" width="71px"  height="64px"></img>
		  </div>
	
		<div style="margin-left:12%;float:left">
		  	<div id="title" style="text-align: center">广东技术师范学院门诊部</div>
		  	<div id="title" style="text-align: center">处方笺</div>
	  	</div>
  	</div>
	<table cellSpacing="0" cellPadding="0" style="width:700px">
		<%--<tr height="45px">
    		<td id="title" colspan="6" align="center" valign="bottom">广东技术师范学院门诊部</td>
		</tr>
		<tr  height="45px">
    		<td id="title" colspan="6" align="center" valign="middle">处方笺</td>
		</tr>
		
		--%><tr height="30px">
			<td align="left" colspan="6" valign="bottom">
				&nbsp;医保卡号/校医疗证号：${personMap['card_num']}
				&nbsp;&nbsp;处方编号：${personMap['number'] }
			</td>
		</tr>
		
		<tr height="0px">
			<td colspan="6">
				<hr color="#838B8B" align="center" size="2" style="width:98%;" />
			</td>
		</tr>
		
		<tr  height="30px">
			<td colspan="6">
				<div>
					<span style="margin-left:20px">姓名：${personMap['name']}</span>
					<span style="margin-left:10px">性别：${personMap['sex']}</span>
					<span style="margin-left:10px">年龄：${personMap['age']}</span>
					<span style="margin-left:20px">时间：<input type="text" id="print_time" name="print_time" style="border:0px;vertical-align:middle;font-size:11"></span>
				</div>
			</td>
			<%-- <td align="right" colspan="2">姓名：${personMap['name']}</td>
			<td align="center" colspan="2">性别：${personMap['sex']}</td>
			<td align="left" colspan="2">年龄：${personMap['age']}</td> --%>
		</tr>
		<tr  height="30px">
			<td colspan="6">
			<div style="display:inline;">人员费别:学生<input type="checkbox"  value="0" name="student" <c:if test="${personMap['type'] == 0}">checked</c:if> />10%
					教工<input type="checkbox"  value="1" name="teacher" <c:if test="${personMap['type'] == 1}">checked</c:if> />10%
					退休<input type="checkbox"  value="2" name="retire" <c:if test="${personMap['type'] == 2}">checked</c:if> />5%
					离休<input type="checkbox"  value="3" name="leave" <c:if test="${personMap['type'] == 3}">checked</c:if> />0%
					全费<input type="checkbox"  value="4" name="fullFee" <c:if test="${personMap['type'] == 4}">checked</c:if> />100%
				</div>
			</td>
			<%-- <td align="left" width="13.5%">&nbsp;人员费别：</td>
			<td align="left" width="13%">学生<input type="checkbox" name="student" <c:if test="${personMap['type'] == 0}">checked</c:if> >10%</td>
			<td align="left" width="13%">教工<input type="checkbox" name="teacher" <c:if test="${personMap['type'] == 1}">checked</c:if> >10%</td>
			<td align="left" width="12.5%">退休<input type="checkbox" name="retire" <c:if test="${personMap['type'] == 2}">checked</c:if> >5%</td>
			<td align="left" width="12.5%">离休<input type="checkbox" name="leave" <c:if test="${personMap['type'] == 3}">checked</c:if> >0%</td>
			<td align="left" width="23%">全费<input type="checkbox" name="fullFee" <c:if test="${personMap['type'] == 4}">checked</c:if> >100%</td>
		</tr> --%>
		<tr  height="40px">
			<td align="left" colspan="5">&nbsp;工作部门/学院班系：${personMap['class']}</td>
			
		</tr>
		
		<tr height="30px">
			<td align="left" colspan="6" >
				<span style="margin-left:20px;">住址/电话：${personMap['address']}</span>
				<span style="margin-left:20px;">开具日期：${personMap['currentDate']}</span>
			</td>
			
			<%-- <td align="right" valign="middle" colspan="3">
				<span style="margin-left:50px;">开具日期：${personMap['currentDate']}</span>
			</td> --%>
		</tr>
		
		<tr  height="30px">
			<td colspan="6">
				<table>
					<tr> 
						<td align="right" valign="top" style="text-align:right">&nbsp;&nbsp;临床诊断：</td>
						<td align="left" valign="top">
							<table cellpadding="0" cellspacing="0">
								<c:forEach var="obj" items="${fn:split(diagnoseMap['description'],'||')}" varStatus="status">
									<c:if test="${obj != ''}">
										<tr>
											<td>${status.count}、${obj}</td>
										</tr>
									</c:if>
								</c:forEach>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		
		<tr  height="0px">
			<td colspan="6">
				<hr color="#838B8B" align="center" size="2" style="width:98%;" />
			</td>
		</tr>
		
		<tr  height="20px">
    		<td id="title" colspan="6" align="left" valign="bottom"><font style="margin-left:1cm;">Rp.</font></td>
		</tr>
		<tr  height="50px">
			<td colspan="6" align="center">
				<table cellpadding="0" cellspacing="0" style="float:left;padding-left:50px">
					<c:if test="${diagnoseMap['post_number'] == null}">
						<c:forEach var="obj" items="${list}" varStatus="status">
							<tr>
								<td colspan="3">
									${status.count}、${obj.name}&nbsp;&nbsp;${obj.spec}×${obj.quantity }${obj.unit }
									<input type="text" id="amount" name="amount" value="${obj.amount }" style="border:0;;width:50px;BORDER-RIGHT: medium none;BORDER-TOP: medium none;BORDER-LEFT: medium none;BORDER-BOTTOM:medium none;text-align:right">元
								</td>
							</tr>
							<tr><td></td><td colspan="2">Sig：${obj.use_method}&nbsp;&nbsp;&nbsp;&nbsp;${obj.consumption}&nbsp;&nbsp;&nbsp;&nbsp;${obj.times}</td></tr>
						</c:forEach>
					</c:if>
					<c:if test="${diagnoseMap['post_number'] != null}">
						<tr>
							<c:forEach var="obj" items="${list}" varStatus="status">
								<td>
									${obj.name}&nbsp;&nbsp;${obj.quantity}${obj.spec}
								</td>
								<c:if test="${status.count % 3 == 0}">
									<tr></tr>
								</c:if>
							</c:forEach>
						</tr>
					</c:if>
				</table>
			</td>
		</tr>
		<c:if test="${diagnoseMap['post_number'] == null}">
			<tr>
				<td colspan="6">
					<table>
						<tr>
							<td>
								<div>
								<span style="width:100px"></span>(以下为空白)
								</div>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</c:if>
		<c:if test="${diagnoseMap['post_number'] != null}">
			<tr><td></td><td>共：${diagnoseMap['post_number']}帖</td></tr>
		</c:if>
	</table>
	<div style="padding-top:100px;">
		<div><hr color="#838B8B" align="center" size="2" style="width:98%;" /></div>
		<div style="margin-left:50px">
			<span style="width:25px"></span>医师：<input type="text" class="general" style="width:80" value="${personMap['user_name']}" readonly/>
			<span style="width:30px"></span>药品金额：
			<input type="text" id="amountTotal" class="general" style="width:80" readonly/>
		</div>
		<div style="margin-left:50px">
			实收金额：<input type="text" class="general" style="width:80" readonly/>
			<span style="width:30px"></span>审核药师：
			<input type="text" class="general" style="width:80" readonly/>
		</div>
	</div>
	</div>
	
  </body>
</html>
